package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.JianchaForm;
import com.sample.javabean.Jiancha;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class JianchaAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(JianchaAction.class);
    	 	private Pager<Jiancha> pageList;
    	 	private String tctime;
    	 	private  Jiancha  jiancha=new  Jiancha();
    	 	private  JianchaForm jianchaForm=new  JianchaForm();
    	 	
    	 	
    	 	/**
    	 	 * 体检信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputJiancha()throws Exception{
    	 		
    	 		return "inputJiancha";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加体检信息");
    	 			if(jianchaForm!=null){
    	 				Jiancha jiancha =new Jiancha();
    	 				 //将jianchaForm中的属性值一一对应jiancha的对应属性
    	 				jiancha.setClassName(jianchaForm.getClassName());
    	 				jiancha.setTctime(jianchaForm.getTctime());
    	 				jiancha.setCcheck(jianchaForm.getCcheck());
    	 				jiancha.setNname(jianchaForm.getNname());
    	 				jiancha.setZzhuang(jianchaForm.getZzhuang());
    	 				jiancha.setDeal(jianchaForm.getDeal());
    	 				
    	 			
    	 				
    	 			   //调用方法
    	 				jiancha.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputJiancha";
    	 	}
    	 	
    		public String list()throws Exception{
    			Jiancha jianchaModel =new Jiancha();
    	 		pageList =jianchaModel.list(page, size, jianchaForm);
    	 		return "listJiancha";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(jianchaForm!=null){
    	 				jiancha.setTctime(tctime);
    	 				jiancha.delJiancha();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editJiancha()throws Exception{
    	 		try{
    	 			jiancha.setTctime(tctime);
    	 			jiancha.load();
    	 			return "editJiancha";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		try{
    	 			
    	 			if(jianchaForm!=null){
    	 				jiancha.setClassName(jianchaForm.getClassName());
    	 				jiancha.setTctime(jianchaForm.getTctime());
    	 				jiancha.setCcheck(jianchaForm.getCcheck());
    	 				jiancha.setNname(jianchaForm.getNname());
    	 				jiancha.setZzhuang(jianchaForm.getZzhuang());
    	 				jiancha.setDeal(jianchaForm.getDeal());
    	 				
    	 				jiancha.editJiancha();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Jiancha> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Jiancha> pageList) {
				this.pageList = pageList;
			}
			public String getTctime() {
				return tctime;
			}
			public void setTctime(String tctime) {
				this.tctime = tctime;
			}
			public Jiancha getJiancha() {
				return jiancha;
			}
			public void setJiancha(Jiancha jiancha) {
				this.jiancha = jiancha;
			}
			public JianchaForm getJianchaForm() {
				return jianchaForm;
			}
			public void setJianchaForm(JianchaForm jianchaForm) {
				this.jianchaForm = jianchaForm;
			}
			public static Log getLog() {
				return log;
			}
			
}
